<template>
	<view>
		<input v-model="inp"></input>
		<button @click='add'>留言</button>
		
		<view class="msg" v-for="(v,i) in arr"><text>{{v}}</text> <button @click='del(i)' class="btn" size="mini">删除</button></view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inp:'',
				arr:[]
			}
		},
		methods: {
			add(){
				//push 数组的最后添加数据
				this.arr.push(this.inp)
				this.inp=''
			},
			del(index){
				this.arr.splice(index,1)
			}
		}
	}
</script>

<style>
input{
	border: 1px solid #eee;
	height: 60rpx;
}
.msg{
	display: flex;
	justify-content: space-between;
}
</style>
